Skip to content

gh-154942: Refresh statistics.kde cache after same-length data changes - #155034

Open
Taeknology wants to merge 1 commit into
python:mainfrom
Taeknology:fix/gh-154942-kde-cache
Open

gh-154942: Refresh statistics.kde cache after same-length data changes#155034
Taeknology wants to merge 1 commit into
python:mainfrom
Taeknology:fix/gh-154942-kde-cache

Conversation

@Taeknology

@Taeknology Taeknology commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Fixes #154942.

statistics.kde() now detects changes to the contents of mutable data sequences for bounded-support kernels. Previously, its sorted sample cache was refreshed only when the sequence length changed, so replacing a value without changing the length could produce a stale estimate.

The bounded-support path now compares the current data with a tuple snapshot and rebuilds the sorted sample only when the contents change. This preserves online updates while keeping bounded- and unbounded-support kernels consistent.

The statistics test suite passes, including new regression coverage for PDF and CDF estimates after a same-length value replacement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

statistics.kde has inconsistent and counterintuitive caching behaviour

1 participant